﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
    >
<html lang="en">
<head>
<title>Привет [%title%]</title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />

<LINK rel="shortcut icon" href="/favicon.ico" type="image/x-icon">

<link rel="stylesheet" href="/s/jquery.jscrollpane.css" type="text/css">
<link rel="stylesheet" href="/s/jquery.jscrollpane.lozenge.css?[%rand%]" type="text/css">

<link rel="stylesheet" href="/s/main.css?[%rand%]" type="text/css">
<link rel="stylesheet" href="/s/main_layout.css?[%rand%]" type="text/css">
<link rel="stylesheet" href="/s/chat.css?[%rand%]" type="text/css">

<link rel="stylesheet" href="/s/game/main.css?[%rand%]" type="text/css">
<link rel="stylesheet" href="/s/game/task.css?[%rand%]" type="text/css">


<script src="/j/lib/jquery-1.6.2.js"></script>
<script src="/j/lib/jquery.tmpl.js"></script>

<script src="/j/lib/jquery.jscrollpane.min.js"></script>
<script src="/j/lib/jquery.mousewheel.min.js"></script>
<script src="/j/lib/jquery.json-2.2.min.js"></script>
<script src="/j/lib/jquery.caret.min.js"></script>
<script src="/j/lib/jquery.cookie.js"></script>

<!--
<script src="/j/mc/mc.cmd.js"></script>
<script src="/j/mc/mc.panel.js"></script>
<script src="/j/mc/mc.template.js"></script>
<script src="/j/mc/mc.main.js"></script>
<script src="/j/mc/mc.smiles.js"></script>
<script src="/j/mc/mc.translate.js"></script>
<script src="/j/mc/mc.transport.js"></script>
<script src="/j/mc/mc.tape.js"></script>
<script src="/j/mc/mc.inputer.js"></script>
<script src="/j/mc/mc.js"></script>
-->

<script src="/j/mc/mc.cmd.js?[%rand%]"></script>
<script src="/j/mc/mc.panel.js?[%rand%]"></script>
<script src="/j/mc/mc.template.js?[%rand%]"></script>
<script src="/j/mc/mc.main.js?[%rand%]"></script>
<script src="/j/mc/mc.smiles.js?[%rand%]"></script>
<script src="/j/mc/mc.translate.js?[%rand%]"></script>
<script src="/j/mc/mc.transport.js?[%rand%]"></script>
<script src="/j/mc/mc.tape.js?[%rand%]"></script>
<script src="/j/mc/mc.inputer.js?[%rand%]"></script>
<script src="/j/mc/mc.js?[%rand%]"></script>

<script>
[%for obj=premake%]
if(!window.[%obj%]){
	window.[%obj%] = function(){};
}
[%end%]
</script>

[%for file=preload%]
<script src="[%file%]?[%rand%]"></script>
[%end%]

<script>
var path_to_img = "[%path_to_img%]";
var min_task_delay = [%min_task_delay%];
var user_id = [%user_id%];

function dbg(str){
	$("#dbg div:eq(1)").html(str);
}
function tooltip(text){
}
var scroll_pane = {
	showArrows: true,
	horizontalGutter: 10
};
$(function(){
	$.ajaxSetup({cache: false});
	$("#messages").jScrollPane(scroll_pane);
	$(window).resize(onres);
	if("onorientationchange" in window){
		window.addEventListener("orientationchange",function(){
			$(window).trigger('resize');
		},false);
	}
	onres();
	var p = {
		main: "main",
		tape: "messages",
		panel: "panel",
		topic: "topic",
		[%if config;     "config: "     _ config.json     _ ","; end%]
		[%if setting;    "setting: "    _ setting.json    _ ","; end%]
		[%if run;        "run: '"       _ run             _ "',";end%]
		[%if run_data;   "run_data: "   _ run_data.json   _ ","; end%]
		[%if start;      "start: "      _ start           _ ","; end%]
		[%if start_data; "start_data: " _ start_data.json _ ","; end%]
		[%if extra_data; "extra_data: " _ extra_data.json(1) _ ","; end%]
		login: '[%login%]',
		pass: '[%password%]'
	};
	mc.try_start = 0;
	try_start(p);
});
var go_event;
function try_start(p){
	if(window.mc && mc.check_load && mc.check_load()){
		mc.start(p);
		go_event = true;
	}else{
		dbg(mc.error);
		if(++mc.try_start > 10 ){
			alert("cannot start "+mc.error);
			return;
		}
		window.setTimeout(try_start,500,p);
	}
}
function onres(event){
	var main = $("#main").height();
	var dbg = $("#dbg").height();
	var mess = $("#messages");
	var pan = $("#panel").height();
	var tp = $("#topic").height();
	var w = $(window).height();
	mess.height(w - (main + dbg + pan + tp + 10 ));
	var api;
	if((api = mess.data("jsp"))){
		api.reinitialise();
		api.scrollToBottom();
	}
	$("div.scrolled").each(function(){
		var api = $(this).data("jsp");
		if(api){
			api.reinitialise();
		}
		return true;
	});
}
</script>

</head>
<body>
<div id="dbg">
	<div>
		<a href="/">index</a>
		<a href="?[%rand%]">reload</a>
		<a href="/enter.pl?cmd=logout;[%rand%]">logout</a>
	</div>
	<div></div>
</div>

<div id="main"></div>

<div id="chat">
	<div id="messages"></div>
	<div id="panel"></div>
	<div id="topic"></div>
</div>

<div id="tooltip"></div>

</body>
</html>
